import App from './App.vue'
import uviewPlus from 'uview-plus'
import store from './store/index.js'
import request from './utils/request.js'
import stream from './utils/stream.js'
import { createSSRApp } from 'vue'
// import vConsole from 'vconsole'
// const v = new vConsole()
export function createApp() {
  const app = createSSRApp(App)
  app.config.globalProperties.$request = request;
  app.config.globalProperties.$stream = stream;
  app.config.errorHandler = (msg,instance,info) => {
	  console.log(msg,instance,info)
  }
  app.config.globalProperties.$checkAuth = () => {
	  return new Promise((resolve,reject) => {
		  request({
			  url:'/api/v1/miletus/user/freeCount?modeCode=1',
			  method: 'get',
		  }).then(res => {
			  console.log(res,'ressssssssssss')
			  store.state.openVip = !res;
			  if(!res) {
				  // 如果没有次数更新一下用户信息，防止购买过的用户，没有及时刷新个人信息
				  store.dispatch('getUserInfo')
			  }
			  resolve(res)
		  }).catch(err => {
			  reject()
		  })
	  })
  }
  app
  .use(uviewPlus)
  .use(store)
  return {
    app
  }
}